package au.org.nh.util.file;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StringReader;

public class ResourceFileReader {

	public StringReader getFile(final String fileName) {
		final BufferedReader reader = new BufferedReader(new InputStreamReader(
				getStream(fileName)));
		final StringBuffer result = new StringBuffer(1024 * 5);
		String line = null;
		try {
			while ((line = reader.readLine()) != null) {
				result.append(line);
			}
		} catch (final IOException e) {
			e.printStackTrace();
		}
		final String redString = result.toString();
		return new StringReader(redString);
	}

	private InputStream getStream(final String fileName) {
		return getClass().getClassLoader().getResourceAsStream(fileName);
	}

}
